package com.smartview.common.filter;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

import com.smartview.common.xss.XSSEncoder;

public class XSSRequestWrapper extends HttpServletRequestWrapper {
   
   public XSSRequestWrapper(HttpServletRequest wrapper) {
      super(wrapper);
   }
   
   public String getXSSEncodedParameter(String name)
   {
	   String paramValue = super.getParameter(name);
	   
	   paramValue = XSSEncoder.encode(paramValue);	   
	   
	   return paramValue;
   }   
   
   public Map getParameterMap()
   {
	   HashMap map = new HashMap();
	   Enumeration names = getParameterNames();
	   
	   while(names.hasMoreElements())
	   {
		   String name = (String)names.nextElement();
		   map.put(name, XSSEncoder.encode(getParameterValues(name)));
	   }

	   return map;	   	 
   }
   
}
